import java.util.ArrayList;
import java.util.List;

abstract class FileSystemItem {
    protected String name;
    public FileSystemItem(String name) {
        this.name = name;
    }
    public String getName(){
        return name;
    }
    public abstract long getSize();
}
class File extends FileSystemItem {
    private long size;
    public File(String name,long size) {
        super(name);
        this.size = size;
    }

    @Override
    public long getSize() {
        return size;
    }
}
class Directory extends FileSystemItem {
    private List<FileSystemItem> items = new ArrayList<>();

    public Directory(String name) {
        super(name);
    }
    public void addItem(FileSystemItem item){
        items.add(item);
    }
    public void removeItem(FileSystemItem item){
        items.remove(item);
    }
    public List<FileSystemItem> getItems(){
        return items;
    }

    @Override
    public long getSize() {
        long totalSize = 0;
        for(FileSystemItem item : items){
            totalSize += item.getSize();
        }
        return totalSize;
    }
}
